package com.imodia.checkoo.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.hsq.commons.util.db.GenericIbatisDao;
import com.hsq.commons.util.db.SqlParam;
import com.hsq.commons.util.db.annotation.SqlSpace;
import com.imodia.checkoo.bean.CmsUserBean;
import com.imodia.checkoo.service.CmsUserService;

@SqlSpace(spaceName = "cmsuser")
@Service("cmsUserService")
public class CmsUserServiceImpl extends GenericIbatisDao<CmsUserBean, Integer> implements CmsUserService {
	

	public void clear(int departMentId){
		String sql1 = "update cms_user set department_id = 0 where department_id = "+departMentId;
		this.getSqlDao().update(sql1);
	}
	
	public void updateDepartMent(int departMentId,int userId){
		String sql2 = "update cms_user set department_id = "+departMentId+" where id = "+userId;
		this.getSqlDao().update(sql2);
	}
	
	public List<CmsUserBean> query(int departMentId){
		SqlParam sql = new SqlParam();
		sql.andEqualTo("department_id", String.valueOf(departMentId));
		return list(sql);
	}
	
	public void updateLastLoginTime(int userId){
		String sql2 = "update cms_user set last_login_time = now() where id = "+userId;
		this.getSqlDao().update(sql2);
	}
	
	
}